﻿<Frame x:Class="StockManagement.Views.OutwardProduct"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
    <Frame.Content>
        <Grid x:Name="_mainGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="0.3*"></ColumnDefinition>
                <ColumnDefinition Width="0.7*"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <Label Content="Product Code :" Margin="2"  Padding="3" Height="25"></Label>
            <ComboBox Grid.Column="1" Margin="2" Padding="3" x:Name="cmbInwardProductCode"
                                   ItemsSource="{Binding Path=OutwardProductCollection}"  DisplayMemberPath="ProductCode" SelectedValuePath="ProductID"
                                  SelectedItem="{Binding Path=SelectedProduct}" HorizontalAlignment="Stretch" VerticalAlignment="Center"></ComboBox>

            <Label Content="Product name :" Grid.Row="1" Margin="2"  Padding="3" Height="25"></Label>
            <Border  Grid.Row="1" Grid.Column="1" Margin="2" BorderThickness="1" BorderBrush="{StaticResource DefaultControlForegroundBrush}">
                <TextBlock  Padding="3" Text="{Binding Path=SelectedProduct.ProductName}" HorizontalAlignment="Stretch" VerticalAlignment="Center"></TextBlock>
            </Border>

            <Label Content="Product Type :" Grid.Row="2" Margin="2"  Padding="3" Height="25"></Label>
            <Border  Grid.Row="2" Grid.Column="1" Margin="2" BorderThickness="1" BorderBrush="{StaticResource DefaultControlForegroundBrush}">
                <TextBlock  Padding="3" Text="{Binding Path=SelectedProduct.ProductType}" HorizontalAlignment="Stretch" VerticalAlignment="Center"></TextBlock>
            </Border>

            <Label Margin="2" Grid.Row="3" Padding="3" Content="Product Status" Height="25"></Label>
            <Border  Grid.Row="3" Grid.Column="1" Margin="2" BorderThickness="1" BorderBrush="{StaticResource DefaultControlForegroundBrush}">
                <TextBlock  Padding="3" Text="{Binding Path=SelectedProduct.ProductStatus}" HorizontalAlignment="Stretch" VerticalAlignment="Center"></TextBlock>
            </Border>
            
            <Label Content="Purchaser :" Grid.Row="4" Margin="2"  Padding="3" Height="25"></Label>
            <TextBox Grid.Row="4" Grid.Column="1" Margin="2"  Padding="3" Text="{Binding Path=Purchaser,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch" VerticalAlignment="Center"></TextBox>

            <Label Content="Purchased Date :" Grid.Row="5" Margin="2"  Padding="3" Height="25"></Label>
            <Border  Grid.Row="5" Grid.Column="1" Margin="2" BorderThickness="1" BorderBrush="{StaticResource DefaultControlForegroundBrush}">
                <TextBlock  Padding="3" Text="{Binding sys:DateTime.Now, StringFormat={}{0:dd-MMM-yyyy}}" HorizontalAlignment="Stretch" VerticalAlignment="Center"></TextBlock>
            </Border>

            <DataGrid x:Name="selProdDatagrid" Grid.RowSpan="6" Grid.Column="2"
                                  ItemsSource="{Binding Path= SelectedProduct.MaterialsQuantity}">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Material Name" Binding="{Binding Path=MaterialName}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="Material Code" Binding="{Binding Path=MaterialCode}"  IsReadOnly="True"/>
                    <DataGridTextColumn Header="Quantity" Binding="{Binding Path=MaterialQuantity}"  IsReadOnly="True"/>
                </DataGrid.Columns>
            </DataGrid>
            <StackPanel Grid.Row="6" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Command="{Binding Path=UpdateCommand}">Update as Delivered</Button>
                <Button Command="{Binding Path=DiscardCommand}">Discard</Button>
            </StackPanel>
        </Grid>
    </Frame.Content>
</Frame>
